-
Notifications
You must be signed in to change notification settings - Fork 73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, awesome!
src/typescript-service.ts
Outdated
@@ -173,6 +174,8 @@ export class TypeScriptService { | |||
} | |||
}; | |||
|
|||
private completionWithSnippets: boolean = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add docblock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is a bit vague. Please add a supports
prefix or something like that
src/typescript-service.ts
Outdated
@@ -200,6 +203,10 @@ export class TypeScriptService { | |||
if (params.rootUri || params.rootPath) { | |||
this.root = params.rootPath || uri2path(params.rootUri!); | |||
this.rootUri = params.rootUri || path2uri(params.rootPath!); | |||
|
|||
if (params.capabilities.textDocument && params.capabilities.textDocument.completion && params.capabilities.textDocument.completion.completionItem) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the if
, just set the flag to the result of the boolean expression
src/typescript-service.ts
Outdated
@@ -998,10 +1005,19 @@ export class TypeScriptService { | |||
if (completions == null) { | |||
return []; | |||
} | |||
function createSnippet(entry: ts.CompletionEntryDetails): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only used in one place, so no benefit to put in an inline function, but makes the code not chronological. Better to do it inline and document
@@ -31,7 +36,7 @@ export interface TestContext { | |||
* @param createService A factory that creates the TypeScript service. Allows to test subclasses of TypeScriptService | |||
* @param files A Map from URI to file content of files that should be available in the workspace | |||
*/ | |||
export const initializeTypeScriptService = (createService: TypeScriptServiceFactory, rootUri: string, files: Map<string, string>) => async function (this: TestContext & IBeforeAndAfterContext): Promise<void> { | |||
export const initializeTypeScriptService = (createService: TypeScriptServiceFactory, rootUri: string, files: Map<string, string>, clientCapabilities?: ClientCapabilities) => async function (this: TestContext & IBeforeAndAfterContext): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the default value into the parameter
@@ -16,6 +16,11 @@ import { IBeforeAndAfterContext, ISuiteCallbackContext, ITestCallbackContext } f | |||
chai.use(chaiAsPromised); | |||
const assert = chai.assert; | |||
|
|||
const defaultCapabilities: ClientCapabilities = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFAULT_CAPABILITIES
src/typescript-service.ts
Outdated
const parameters = entry.displayParts | ||
.filter(p => p.kind === 'parameterName') | ||
.map(p => { | ||
index++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map
passes the index as a second parameter
Codecov Report
@@ Coverage Diff @@
## master #323 +/- ##
==========================================
+ Coverage 59.64% 59.88% +0.24%
==========================================
Files 14 14
Lines 2126 2139 +13
Branches 347 350 +3
==========================================
+ Hits 1268 1281 +13
Misses 708 708
Partials 150 150
Continue to review full report at Codecov.
|
Rename to supportsCompletionWithSnippets + doctype Fix up assignment Pull createSnippet into function Use index param from map
rename constant, use as default value
Great, thanks for the reviews! |
If the client sends
snippetSupport: true
in the textDocument/completion/completionItem capability, this PR adds support for responding with these fields set in CompletionItem:Both VS Code and Sublime Text support these snippets.
For clients not supporting snippets, CompletionItem will now contain